package com.myapp.api.entity;

import javax.validation.constraints.*;
import java.util.Date;

public class Course {
    private Integer id;

    @NotBlank(message = "课程编号不能为空")
    @Size(min = 2, max = 20, message = "课程编号长度在 2 到 20 之间")
    @Pattern(regexp = "^[1-9]\\d*$", message = "课程编号必须为数字")
    private String cid;

    @NotBlank(message = "教师工号不能为空")
    @Size(min = 2, max = 20, message = "课教师工号长度在 2 到 20 之间")
    @Pattern(regexp = "^[1-9]\\d*$", message = "教师工号必须为数字")
    private String tid;

    @NotBlank(message = "课程名称不能为空")
    @Size(min = 2, max = 30, message = "课程名称长度在 2 到 30 之间")
    private String cname;

    @NotNull(message = "学分不能为空")
    @Digits(integer = 1, fraction = 1, message = "非法的学分")
    @DecimalMax(value = "4.5",message = "学分最大值 4.5")
    @DecimalMin(value = "1.0",message = "学分最小值 1.0")
    private Double credit;

    @NotNull(message = "可供选课数不能为空")
    @Digits(integer = 2, fraction = 0, message = "非法的可供选课数")
    @DecimalMin(value = "0", message = "可供开课数最小值 0")
    @DecimalMax(value = "50", message = "可供开课数最大值 50")
    private Integer count;

    private Date createtime;

    private Date updatetime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCid() {
        return cid;
    }

    public void setCid(String cid) {
        this.cid = cid == null ? null : cid.trim();
    }

    public String getTid() {
        return tid;
    }

    public void setTid(String tid) {
        this.tid = tid == null ? null : tid.trim();
    }

    public String getCname() {
        return cname;
    }

    public void setCname(String cname) {
        this.cname = cname == null ? null : cname.trim();
    }

    public Double getCredit() {
        return credit;
    }

    public void setCredit(Double credit) {
        this.credit = credit;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Date getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }

    public Date getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(Date updatetime) {
        this.updatetime = updatetime;
    }
}